﻿<ds:TestingContext x:Class="DragonSpark.Testing.Runtime.ExceptionHandling"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:ds="http://framework.dragonspark.us" xmlns:reflection="clr-namespace:System.Reflection;assembly=mscorlib"
	xmlns:dragonSpark="clr-namespace:DragonSpark;assembly=DragonSpark"
    xmlns:logging="clr-namespace:DragonSpark.Logging;assembly=DragonSpark"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:testObjects="clr-namespace:DragonSpark.Testing.TestObjects"
>
	<ds:AssignServiceLocatorCommand />
	<ds:RegisterFromMetadataCommand />
	<ds:LoggingConfiguration>
		<ds:EventListenerDefinition>
			<ds:Instance>
				<testObjects:TestEventListener Level="Informational" />
			</ds:Instance>
			<ds:EventListenerDefinition.Registrations>
                <ds:DictionaryOfT KeyType="{x:Type system:Type}" TypeArgument="{x:Type logging:EventSourceRegistration}">
                    <ds:KeyValuePair Key="{x:Type logging:ILogger}">
                        <logging:EventSourceRegistration Level="Informational" />
                    </ds:KeyValuePair>
                </ds:DictionaryOfT>
			</ds:EventListenerDefinition.Registrations>
		</ds:EventListenerDefinition>
		<ds:EventListenerDefinition>
			<ds:Instance>
				<testObjects:TestEventListener Level="Warning" />
			</ds:Instance>
			<ds:EventListenerDefinition.Registrations>
                <ds:DictionaryOfT KeyType="{x:Type system:Type}" TypeArgument="{x:Type logging:EventSourceRegistration}">
                    <ds:KeyValuePair Key="{x:Type logging:ILogger}">
                        <logging:EventSourceRegistration Level="Warning" />
                    </ds:KeyValuePair>
                </ds:DictionaryOfT>
			</ds:EventListenerDefinition.Registrations>
		</ds:EventListenerDefinition>
		<ds:EventListenerDefinition>
			<ds:Instance>
				<testObjects:TestEventListener Level="Error" />
			</ds:Instance>
			<ds:EventListenerDefinition.Registrations>
                <ds:DictionaryOfT KeyType="{x:Type system:Type}" TypeArgument="{x:Type logging:EventSourceRegistration}">
                    <ds:KeyValuePair Key="{x:Type logging:ILogger}">
                        <logging:EventSourceRegistration Level="Error" />
                    </ds:KeyValuePair>
                </ds:DictionaryOfT>
			</ds:EventListenerDefinition.Registrations>
		</ds:EventListenerDefinition>
		<ds:EventListenerDefinition>
			<ds:Instance>
				<testObjects:TestEventListener Level="Critical" />
			</ds:Instance>
			<ds:EventListenerDefinition.Registrations>
                <ds:DictionaryOfT KeyType="{x:Type system:Type}" TypeArgument="{x:Type logging:EventSourceRegistration}">
                    <ds:KeyValuePair Key="{x:Type logging:ILogger}">
                        <logging:EventSourceRegistration Level="Critical" />
                    </ds:KeyValuePair>
                </ds:DictionaryOfT>
			</ds:EventListenerDefinition.Registrations>
		</ds:EventListenerDefinition>
	</ds:LoggingConfiguration>
	
	<ds:ExceptionHandlingConfiguration>
		<ds:ExceptionPolicyDefinition PolicyName="{x:Static logging:EnterpriseLibraryExceptionHandler.DefaultExceptionPolicy}">
			<ds:ExceptionPolicyEntry  ExceptionType="{x:Type system:Exception}" Action="ThrowNewException">
				<logging:LogExceptionHandler />
				<ds:WrapHandler WrapExceptionType="{x:Type system:ApplicationException}" Message="{}An exception was thrown. Context Id: {handlingInstanceID}" />
			</ds:ExceptionPolicyEntry>
			<ds:ExceptionPolicyEntry ExceptionType="{x:Type testObjects:TestingException}" Action="None">
				<logging:LogExceptionHandler />
			</ds:ExceptionPolicyEntry>
			<ds:ExceptionPolicyEntry ExceptionType="{x:Type testObjects:FatalTestingException}" Action="NotifyRethrow">
				<logging:LogFatalExceptionHandler />
			</ds:ExceptionPolicyEntry>
		</ds:ExceptionPolicyDefinition>
	</ds:ExceptionHandlingConfiguration>
	<ds:ApplicationConfigurationCommand>
		<ds:ApplicationConfigurationCommand.ApplicationDetails>
			<dragonSpark:ApplicationDetails
				Title="{ds:Metadata {x:Type reflection:AssemblyTitleAttribute}, 'Title'}"
				Product="{ds:Metadata {x:Type reflection:AssemblyProductAttribute}, 'Product'}"
				Company="{ds:Metadata {x:Type reflection:AssemblyCompanyAttribute}, 'Company'}"
				Description="{ds:Metadata {x:Type reflection:AssemblyDescriptionAttribute}, 'Description'}"
				Configuration="{ds:Metadata {x:Type reflection:AssemblyConfigurationAttribute}, 'Configuration'}"
				Copyright="{ds:Metadata {x:Type reflection:AssemblyCopyrightAttribute}, 'Copyright'}"
				Version="{ds:AssemblyVersion}"
					
				DeploymentDate="3/5/2013"
				CompanyUri="http://framework.dragonspark.us"
			/>
		</ds:ApplicationConfigurationCommand.ApplicationDetails>
	</ds:ApplicationConfigurationCommand>
</ds:TestingContext>